package io操作;

import java.io.*;

public class 字符流写文件 {

    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        //先获取一个字节输出流
        FileOutputStream fos = new FileOutputStream("C:/Test/1.txt");
        //在包装为一个字节字符转换流
        OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
        //在包装为一个字符输出流
//    BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(osw);

        //这些字符输出流的api，写文本内容，就比较方便
        pw.print("哈哈");//不带换行的输出
        pw.println("学习");//带换行
        pw.flush();
        pw.close();
    }
}
